package com.come4loves.game.module.skill;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.PostConstruct;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.come4loves.game.dataconfig.model.BuffEffectConfig;
import com.come4loves.game.module.fight.action.BatchAction;
import com.come4loves.game.module.fight.constants.BuffType;
import com.come4loves.game.module.fight.model.FightCard;

public abstract class AbstractBuffParser {
	protected Logger LOGGER = LoggerFactory.getLogger(this.getClass());
	private static Map<String, AbstractBuffParser> map = new HashMap<>();
	@PostConstruct
	private void init(){
		map.put(buffId(), this);
	}
	
	public abstract String buffId();
	public abstract void parse(FightCard attackerCard,FightCard targetCard, BuffEffectConfig cfg, BatchAction batchAction);
	
	public static AbstractBuffParser get(String buffId){
		return map.get(buffId);
	}
	protected boolean checkBuffAdd(FightCard fightCard, BuffEffectConfig buffEffectConfig, BuffType type){
		if (buffEffectConfig.getUnique() == 0) {
			return true;
		}
		if (fightCard.isBuffAble(type)) {
			return false;
		}
		return true;
	}
}
